package com.xinxin.base.entity;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.Min;
import java.io.Serializable;

/**
 * @author ys
 * @date 2021/4/20
 */
@ApiModel("分页参数")
@Data
public class PageRequest implements Serializable {

    private static final long serialVersionUID = 1206241493188810752L;

    @ApiModelProperty(value = "当前页码", required = true)
    @Min(1)
    private int pageNum = 1;

    @ApiModelProperty(value = "当前页面数据量", required = true)
    @Min(0)
    private int pageSize = 10;

    /**
     * limit offset
     */
    @ApiModelProperty(hidden = true)
    public int getOffset() {
        return (pageNum - 1) * pageSize;
    }
}
